package com.wyx.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wyx.entity.Admin;
import com.wyx.entity.ResultEntity;
import com.wyx.service.AdminService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wyx
 * @since 2022-03-17
 */
@RestController
@RequestMapping("/user")
public class AdminController {
    @Resource
    private AdminService as;
    @GetMapping("/login/{username}/{password}")
    public ResultEntity login(@PathVariable("username") String username,@PathVariable("password") String password){
        QueryWrapper<Admin> wrapper = new QueryWrapper<>();
        wrapper.eq("username",username).eq("password",password);
        Admin one = as.getOne(wrapper);
        System.out.println(one);
        HashMap<Object, Object> map = new HashMap<>();
        if (one!=null){
            return ResultEntity.builder(1,"success").data(one);
        }else {
            return ResultEntity.builder(0,"error").data(null);
        }
    }
}

